using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace LitTools
{
    public class BTNode_Decorator_TimeLoop : BTNode_Deocrator
    {
        private float timeInterval;
        private float lastUpdateTime;

        public BTNode_Decorator_TimeLoop(float interval)
        {
            this.timeInterval = interval;
        }

        protected override void OnStart()
        {
            lastUpdateTime = -1;
        }

        protected override BTNodeState OnUpdate()
        {
            if (Time.time - lastUpdateTime < timeInterval)
                return BTNodeState.Running;
            lastUpdateTime = Time.time;
            return child.Update();
        }

        protected override void OnStop()
        {

        }
    }
}